//
//  CantripStateMachine.h
//  CantripSDK
//
//  Created by James Callender on Thu Apr 25 2002.
//  Copyright (c) 2001 James Callender. All rights reserved.
//

#import <Foundation/Foundation.h>

enum
{
	ANSI_STATE_GROUND = 0,
	ANSI_STATE_ESC = 1,
	ANSI_STATE_ESCINTERM,
	ANSI_STATE_CSIENTRY,
	ANSI_STATE_CSIPARAM,
	ANSI_STATE_CSIINTERM,
	ANSI_STATE_CSIIGNORE,
	ANSI_STATE_DCSENTRY,
	ANSI_STATE_DCSPARAM,
	ANSI_STATE_DCSPASSTHROUGH,
	ANSI_STATE_DCSINTERM,
	ANSI_STATE_DCSIGNORE,
	ANSI_STATE_OSCSTR,
	ANSI_STATE_SOS_PM_APC_STR,
	ANSI_STATE_ANYWHERE // Does not technically exist
};

enum
{
	ANSI_ACTION_IGNORE = 0,
	ANSI_ACTION_PRINT = 1,
	ANSI_ACTION_EXECUTE,
	ANSI_ACTION_COLLECT,
	ANSI_ACTION_PARAM,
	ANSI_ACTION_DISPATCH,
	ANSI_ACTION_HOOK,
	ANSI_ACTION_PUT,
	ANSI_ACTION_UNHOOK,
	ANSI_ACTION_OSC_START,
	ANSI_ACTION_OSC_PUT,
	ANSI_ACTION_OSC_END,
};

#define ESC_CHAR 27

@interface CantripStateMachine : NSObject 
{
	unsigned int mState;
	
	unsigned int numParams;
	int paramValue[16];
	char param[5];
	
	char collect[5];
}

- (unsigned int)state;
- (int)step:(unsigned char)c;
- (int)process:(unsigned char)c;

- (unsigned int)numberOfParams;
- (int)paramAtIndex:(unsigned int)i;

@end
